<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>slice</title>
  </head>
  <body>
    <div class="box">1</div>
    <div class="box">2</div>
    <div class="box">3</div>
    <div class="box">4</div>
    <div class="box">5</div>
  </body>
</html>
<script>
  // DOM
  let divs = document.getElementsByTagName("div");
  console.log(divs); // HTMLCollection

  let divs2 = document.getElementsByClassName(".box");
  console.log(divs2); // HTMLCollection

  let divs3 = document.querySelectorAll("div");
  console.log(divs3 instanceof Array); // NodeList
  console.log(divs3); // NodeList

  // slice
  const sliceArray = Array.prototype.slice.call(divs3); // 将类数组对象转换为数组
  console.log(sliceArray);
</script>
